﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tauren.File.Entity.Input;
using Tauren.File.Service.FileBLL;

namespace Tauren.File.Core.Controllers
{
    /// <summary>
    /// 文件下载
    /// </summary>
    [Route("api/download")]
    [ApiController]
    public class DownloadController : ControllerBase
    {
        IDownloadService bizservice;
        public DownloadController(IDownloadService _bizservice)
        {
            bizservice = _bizservice;
        }
        /// <summary>
        /// 进行文件下载
        /// </summary>
        /// <param name="files"></param>
        /// <returns></returns>
        [HttpPost, Route("v:{version}"), ApiVersion("1.0")]
        public IActionResult Get([FromBody] Files_Input files)
        {
            var model = bizservice.DownloadFile(fileid: files.AutoId);
            return File(model.Buff, model.ContentType, model.fileName); ;
        }
    }
}
